home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Games / MoofWars / Tim's Libraries / Common Stuff.h next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  2.9 KB  |  95 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        Common Stuff.h
  3.  
  4.     Contains:    a simple include file that holds a number of standard functions,constants, and
  5.                  debugging macros.  Anything that isn't likely to change from program to program.
  6.  
  7.     Written by:     
  8.  
  9.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 7/2/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24.  
  25. #ifndef _COMMONSTUFF_
  26. #define _COMMONSTUFF_
  27.  
  28. #pragma once
  29.  
  30. /*********************************************************************************
  31.     DEBUGGING and ERROR HANDLING MACROS
  32.     
  33.     These macros should be used to create code with proper error handling.  In
  34.     the debugging version of the macros, they dump a string to the debugger before
  35.     dropping into the error handler.
  36.     
  37.     To turn debugging off, set the macro qDebugging to 0 before including Common Stuff.
  38.     
  39.     If an application wants to include special debugging code, the proper way to do this
  40.     is with something like:
  41.     
  42.     #if qDebugging
  43.           // do additional sanity checking here.
  44.     #endif
  45.     
  46.     Note that this should only be additional sanity checking code and not eliminate all error
  47.     checking code.
  48.     
  49. *********************************************************************************/
  50. #define qDebugging 0
  51. #ifndef qDebugging
  52.     #define qDebugging 0
  53. #endif
  54.  
  55. #if qDebugging
  56.     #define SIGNAL_ERROR(msg)        {DebugStr(msg); goto error;}
  57. #else
  58.     #define SIGNAL_ERROR(msg)        {goto error;}
  59. #endif
  60.  
  61. #define FAIL_NIL(y,msg)            if (y == NULL) SIGNAL_ERROR(msg)
  62. #define FAIL_OSERR(y,msg)        if (y != noErr) SIGNAL_ERROR(msg)
  63. #define FAIL_FALSE(y,msg)        if (!y) SIGNAL_ERROR(msg)
  64.     
  65.  
  66. /*********************************************************************************
  67.     QUICKDRAW
  68.     
  69.     This includes a standard set of functions and color constants to use in apps
  70.     that use quickdraw.  As written, this will only compile for C++, although the
  71.     functions could be recast as macros.
  72.     
  73. *********************************************************************************/
  74.  
  75. #include <Quickdraw.h>
  76.  
  77. const RGBColor kWhite = {0xFFFF, 0xFFFF, 0xFFFF};
  78. const RGBColor kBlack = {0x0000, 0x0000, 0x0000};
  79. const RGBColor kDarkBlue = {0x0000,0x0000,0x7000};
  80. const RGBColor kLtGrey = {0xC000,0xC000,0xC000};
  81. const RGBColor kMediumGrey = {0x7FFF,0x7FFF,0x7FFF};
  82.  
  83. inline short RectWidth (const Rect& r) {
  84.     return (r.right-r.left);
  85.     }
  86.  
  87. inline short RectHeight (const Rect& r) {
  88.     return (r.bottom - r.top);
  89.     }
  90.  
  91. #endif /* _COMMONSTUFF_ */
  92.  
  93.     
  94.  
  95.